$(document)
.ready(function(){
	 // Setup html5 version       
    function plupload(){  

    	var uploader = new plupload.Uploader({
    		runtimes : 'html5,flash,silverlight,html4',
    		browse_button : 'uploader', // you can pass in id...
    		//container: document.getElementById('container'), // ... or DOM Element itself
    		url : 'upload.do',
    		flash_swf_url : '../js/Moxie.swf',
    		silverlight_xap_url : '../js/Moxie.xap',
    		
    		filters : {
    			max_file_size : '10mb',
    			mime_types: [
    				{title : "Image files", extensions : "jpg,gif,png"},
    				{title : "Zip files", extensions : "zip"}
    			]
    		},

    		init: {
    			PostInit: function() {
    				document.getElementById('filelist').innerHTML = '';

    				document.getElementById('uploadfiles').onclick = function() {
    					uploader.start();
    					return false;
    				};
    			},
    			BeforeUpload : function(up, file) {
    				alert(file.name);
    				up.settings.url = encodeURI("./uploadtest.do?" + "name="+ file.name+"&type="+file.type+"&size="+file.size);

    			},
    			FilesAdded: function(up, files) {
    				plupload.each(files, function(file) {
    					document.getElementById('uploadTable').innerHTML += "<tr id='"+file.id+"'><td>"+file.type+"</td><td>"+file.name+"</td><td><button type='button' id='"+file.id+"btn' onclick=del('"+file.id+"')>删除</button> </td><td id='"+file.id+"'></td></tr>";
    				});
    			},

    			UploadProgress: function(up, file) {
    				document.getElementById(file.id).getElementsByTagName('td')[3].innerHTML = '<td>' + file.percent + "%</td>";
    			},
    			UploadComplete : function(uploader, files) {

    				alert("上传完毕");
    			},
    			FileUploaded : function(up, file) {
    				alert("文件上传成功");
    				up.settings.url = "";
    			},
    			Error: function(up, err) {
    				document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
    			}
    		}
    	});

    	uploader.init();

    }  
      
    plupload();  
      
    $('#Reload').delegate($(this),"click",function(){  
        plupload();  
    });  


	
});